package com.ruoyi.record.service.impl;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.record.mapper.RecordLeaveMapper;
import com.ruoyi.record.domain.RecordLeave;
import com.ruoyi.record.service.IRecordLeaveService;
import com.ruoyi.common.core.text.Convert;

/**
 * 请假记录Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-11-10
 */
@Service
public class RecordLeaveServiceImpl extends ServiceImpl<RecordLeaveMapper, RecordLeave> implements IRecordLeaveService
{
    /**
     * 查询请假记录
     * 
     * @param leaveId 请假记录主键
     * @return 请假记录
     */
    @Override
    public RecordLeave selectRecordLeaveByLeaveId(Long leaveId)
    {
        return baseMapper.selectRecordLeaveByLeaveId(leaveId);
    }

    /**
     * 查询请假记录列表
     * 
     * @param recordLeave 请假记录
     * @return 请假记录
     */
    @Override
    public List<RecordLeave> selectRecordLeaveList(RecordLeave recordLeave)
    {
        return baseMapper.selectRecordLeaveList(recordLeave);
    }

    /**
     * 新增请假记录
     * 
     * @param recordLeave 请假记录
     * @return 结果
     */
    @Override
    public int insertRecordLeave(RecordLeave recordLeave)
    {
        recordLeave.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(recordLeave);
    }

    /**
     * 修改请假记录
     * 
     * @param recordLeave 请假记录
     * @return 结果
     */
    @Override
    public int updateRecordLeave(RecordLeave recordLeave)
    {
        recordLeave.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(recordLeave);
    }

    /**
     * 批量删除请假记录
     * 
     * @param leaveIds 需要删除的请假记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordLeaveByLeaveIds(String leaveIds)
    {
        return baseMapper.deleteBatchIds(Arrays.asList(Convert.toLongArray(leaveIds)));
    }

    /**
     * 删除请假记录信息
     * 
     * @param leaveId 请假记录主键
     * @return 结果
     */
    @Override
    public int deleteRecordLeaveByLeaveId(Long leaveId)
    {
        return baseMapper.deleteById(leaveId);
    }

    /**
     * 查询待审批请假列表
     *
     * @param recordLeave 请假记录
     * @return 请假记录
     */
    @Override
    public List<RecordLeave> selectVerifyLeaveList(RecordLeave recordLeave)
    {
        return baseMapper.selectVerifyLeaveList(recordLeave);
    }

    /**
     * 打印查询
     *
     * @param leaveId 请假记录主键
     * @return 请假记录
     */
    @Override
    public RecordLeave selectRecordLeaveByPrint(Long leaveId)
    {
        return baseMapper.selectRecordLeaveByPrint(leaveId);
    }
}
